<?php


$query = "SELECT * FROM wp_posts";
$data = DBConn::selectAll($query);
foreach($data as $row)
{
	$args = array(
		'title' => $row['post_title'],
		'body' => $row['post_content'],
		'author' => 1,
		'date_added' => strtotime($row['post_date'])
	);
	$new_post = new Post($args);
	$new_post_id = PostMapper::get()->insert($new_post);

	$query = "SELECT * FROM wp_comments WHERE comment_post_ID=" . $row['id'];
	$comment_data = DBConn::selectAll($query);
	foreach($comment_data as $comment_row)
	{
		$args = array(
			'post_id' => $new_post_id,
			'name' => $comment_row['comment_author'],
			'email' => $comment_row['comment_author_email'],
			'url' => $comment_row['comment_author_url'],
			'body' => $comment_row['comment_content'],
			'date_added' => strtotime($comment_row['comment_date'])
		);
		$new_comment = new Comment($args);
		CommentMapper::get()->insert($new_comment);
	}
}

die();
?>